'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var DepartmentSchema = new Schema({
  name: String,
  created_at: { type: Date, default: Date.now },
  updated_at: { type: Date, default: Date.now }
});

DepartmentSchema
  .pre('save', function(next) {
    if (!this.isNew) this.updated_at = Date.now;
    next();
  });
module.exports = mongoose.model('Department', DepartmentSchema);
